package structure;

import java.util.Scanner;

public class Test6 {
    //gcd与lcm不能说的秘密
    public class Main {
        public static void main3(String[] args) {
            Scanner in = new Scanner(System.in);
            int a = in.nextInt();
            while(a-- > 0){
                int find = 0;
                int lcm = in.nextInt();
                int gcd = in.nextInt();
                for(int i = 1;i <= 12;i++){
                    int days = day(i,lcm,gcd);
                    find += days;
                }
                if(find == 1){
                    System.out.println("YES");
                }else {
                    System.out.println("NO");
                }
            }
        }
        public static int day(int month,int lcm,int gcd){
            int num = 0;
            int days = 0;
            if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){
                days = 31;
            }else if(month == 2){
                days = 29;
            }else {
                days = 30;
            }
            for(int i = 1;i <= days;i++){
                if(i * month / numGcd(i,month) == lcm && numGcd(i,month) == gcd){
                    num++;
                }
            }
            return num;
        }
        public static int numGcd(int a,int b){
            while(b != 0){
                int temp = b;
                b = a % b;
                a = temp;
            }
            return a;
        }
    }
    //约瑟夫环<链表>
    static class ListNode {
        private int val;
        public ListNode next;
        public ListNode(int val) {
            this.val = val;
        }
    }
    public ListNode head;
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int m = in.nextInt();
        ListNode head = new ListNode(0);
        ListNode cur = head;
        for(int i = 1;i < n;i++){
            ListNode node = new ListNode(i);
            cur.next = node;
            cur = cur.next;
        }
        cur.next = head;
        for(int i = 0;i <= k;i++){
            cur = cur.next;
        }
        while(n-- > 1){
            for(int i = 1;i < m - 1;i++){
                cur = cur.next;
            }
            cur.next = cur.next.next;
            cur = cur.next;
        }
        System.out.println(cur.val);
    }
    //蓝桥省B 卡片
    public static void main1(String[] args) {
        int[] num = {2021,2021,2021,2021,2021,2021,2021,2021,2021,2021};
        int n = 1;
        outside: while(true){
            int i = n;
            while(i != 0) {
                int c = i % 10;
                num[c]--;
                if(num[c] < 0){
                    break outside;
                }
                i /= 10;
            }
            n++;
        }
        System.out.println(n - 1);
    }
    //NOIP2013 计数问题
    public static void main0(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int x = in.nextInt();
        int h = 0;
        for(int i = 1;i <= n;i++){
            int num = i;
            while(num > 0){
                int a = num % 10;
                if(a == x){
                    h++;
                }
                num /= 10;
            }
        }
        System.out.println(h);
    }
}
